<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<style>
div{width:100px;height:50px; background:red;margin-top:50px;font-size:12px;color:green; filter:alpha(opacity:30);opacity:0.3;}
</style>
<script>

window.onload=function(){
	var div=document.getElementsByTagName('div');
	for(var i=0;i<div.length;i++){
		div[i].timer=null;
		//div[i].onmouseover=function(){
//			move(300,this);	
//		};
//		div[i].onmouseout=function(){
//			move(100,this)	
//		};
		div[0].onclick=function(){
			move(300,this,'width')	
		}
		div[1].onclick=function(){
			move(200,this,'height')	
		}
		div[2].onclick=function(){
			move(24,this,'fontSize')	
		}
		div[3].onmouseover=function(){
			move(100,this,'opacity')	
		}
		div[3].onmouseout=function(){
			move(30,this,'opacity')	
		}

	}
}
function getStyle(obj,attr){
	
	if(obj.currentStyle){
		return obj.currentStyle[attr];	
	}else{
		return getComputedStyle(obj,false)[attr];	
	};	
}
function move(target,obj,attr){
	clearInterval(obj.timer);
	
	obj.timer=setInterval(function(){
		var iCur=0;
		if(attr=='opacity'){
			iCur=parseInt(parseFloat(getStyle(obj,attr)*100));	
		}else{
			iCur=parseInt(getStyle(obj,attr))	
		};
		
		var speed=(target-iCur)/5;
		speed=speed>0?Math.ceil(speed):Math.floor(speed);
		if(obj.style[attr]==target){
			clearInterval(obj.timer)	
		}else{
			if(attr=='opacity'){
				obj.style.opacity=(iCur+speed)/100;
				obj.style.filter='alpha:(opacity:'+(iCur+speed)+')';
				txt.value=obj.style.opacity;
			}else{
				obj.style[attr]=iCur+speed+'px';
			}
		};
	},60)	
};
</script>
</head>

<body>
<div></div>
<div></div>
<div>ffffffffffff</div>
<div></div>
<input type="text" id="txt" value="" />
</body>
</html>
